<template>
    <div class="photoinfo-container">
        <h3>{{ photoinfo.title }}</h3>
        <p class="subtitle">
            <span>发表时间：{{ photoinfo.add_time | dateFormat }}</span>
            <span>点击：{{ photoinfo.click }}次</span>
        </p>
         
         <hr>
          
          <!-- 缩略图区域 -->
        <div class="thumbs">
        <img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100" @click="$preview.open(index, list)" :key="item.src">
        </div>
          <!-- 图片内容区域 -->
          <div class="content" v-html="photoinfo.content"></div>


          <!-- 放置一个现成的评论子组件 -->
          <cmt-box :id="id"></cmt-box>
    </div>
</template>


  <script>
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id, //从路由中获取到的图片Id
      photoinfo: {}, //图片详情
      list: [] //缩略图的数组
    };
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();
  },
  methods: {
    getPhotoInfo() {
      var content =
        "<html><p>以土地供应和管理制度为例，自2012年新一轮土地管理制度改革以来，深圳市逐步建立了土地整备、城市更新等存量土地二次开发新机制，对房地产建设管理提出了新要求。此外，随着“深圳90改革”的推进实施，建设项目审批发生了重大调整，部分环节与房地产市场监管密切相关，相关制度也亟待衔接完善。原办法有关房地产市场监管制度更多是在增量土地供应背景下制定的，有必要按照新时期城市建设发展的新要求进行修订完善。</p></html>";
      var body = {
        status: 0,
        message: [
          {
            id: 0,
            title: "清新有活力的公寓设计 用色彩焕然一新1",
            click: 3,
            content: content,
            add_time: "2015-06-16T03:50:28.000Z"
          },
          {
            id: 1,
            title: "清新有活力的公寓设计 用色彩焕然一新2",
            click: 3,
            content: content,
            add_time: "2015-01-16T03:50:28.000Z"
          },
          {
            id: 2,
            title: "清新有活力的公寓设计 用色彩焕然一新3",
            click: 3,
            content: content,
            add_time: "2015-02-16T03:50:28.000Z"
          },
          {
            id: 3,
            title: "清新有活力的公寓设计 用色彩焕然一新4",
            click: 3,
            content: content,
            add_time: "2015-03-16T03:50:28.000Z"
          },
          {
            id: 4,
            title: "清新有活力的公寓设计 用色彩焕然一新5",
            click: 3,
            content: content,
            add_time: "2015-05-16T03:50:28.000Z"
          },
          {
            id: 5,
            title: "清新有活力的公寓设计 用色彩焕然一新6",
            click: 3,
            content: content,
            add_time: "2015-05-16T03:50:28.000Z"
          }
        ]
      };
      if (body.status == 0) {
        this.photoinfo = body.message[0];
      } else {
        Toast("获取失败...");
      }
    },
    getThumbs() {
        var body = {
            status: 0,
            message: [
            {
                src: "http://img0.imgtn.bdimg.com/it/u=3651472839,2611362103&fm=26&gp=0.jpg"
            },
            {
                src: "http://img3.imgtn.bdimg.com/it/u=133709150,593841139&fm=26&gp=0.jpg"
            },
            {
                src: "http://img5.imgtn.bdimg.com/it/u=1263584704,621551167&fm=26&gp=0.jpg"
            }, 
            {
                src: "http://img2.imgtn.bdimg.com/it/u=2491264017,1651495829&fm=26&gp=0.jpg"
            },
            {
                src: "http://img4.imgtn.bdimg.com/it/u=313691132,2774609708&fm=26&gp=0.jpg"
            },
            {
                src: "http://img5.imgtn.bdimg.com/it/u=518955480,2376059867&fm=200&gp=0.jpg"
            },
            ]
      };
      if(body.status == 0) {
        //   body.message.forEach(item => {
        //       item.w = 600;
        //       item.h = 400;
        //   });
          this.list = body.message;
      }
    }
  },
  components: {
    //注册评论子组件
    "cmt-box": comment
  }
};
</script>

  <style lang="scss" scoped>
.photoinfo-container {
  padding: 3px;
  h3 {
    color: 3#26a2ff;
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
  .thumbs {
      img{
          margin: 10px;
          box-shadow: 0 0 8px #999;
          width: 80px;
          height: 80px;
      }
  }
}
</style>
  